class SupportBoxPickup extends KFAmmoPickup;


state Pickup
{
	// When touched by an actor.
	simulated function Touch(Actor Other)
	{
		local Inventory CurInv;
		local bool bPickedUp;
		local int AmmoPickupAmount;
		local SRPlayerReplicationInfo SRPRI;
		
		SRPRI = SRPlayerReplicationInfo(PlayerController(Pawn(Other).Controller).PlayerReplicationInfo);
		
		if ( SRPRI.ClientVeteranSkill == class'SRVetJuggernaut' && SRPRI.AmmoSupportUsed >= 5 ||
		SRPRI.ClientVeteranSkill == class'SRVetJuggernaut' && SRPRI.SelfAmmoSupportUsed >= 3 )
		{
			return;
		}

		if ( Pawn(Other) != none && Pawn(Other).bCanPickupInventory && Pawn(Other).Controller != none &&
			 FastTrace(Other.Location, Location) )
		{
			KFPCServ(Instigator.Controller).AddZedTimeCharge(12.00);
			for ( CurInv = Other.Inventory; CurInv != none; CurInv = CurInv.Inventory )
			{
				if ( KFAmmunition(CurInv) != none && KFAmmunition(CurInv).bAcceptsAmmoPickups )
				{
					if ( KFAmmunition(CurInv).AmmoPickupAmount > 1 && !( Frag1Ammo(CurInv) != none && SRPRI.ClientVeteranSkill == class'SRVetJuggernaut' ) )
					{
						if ( KFAmmunition(CurInv).AmmoAmount < KFAmmunition(CurInv).MaxAmmo )
						{
							if ( KFPlayerReplicationInfo(Pawn(Other).PlayerReplicationInfo) != none && KFPlayerReplicationInfo(Pawn(Other).PlayerReplicationInfo).ClientVeteranSkill != none )
							{
								AmmoPickupAmount = 0.34 * (KFAmmunition(CurInv).MaxAmmo * 0.16) * KFPlayerReplicationInfo(Pawn(Other).PlayerReplicationInfo).ClientVeteranSkill.static.GetAmmoPickupMod(KFPlayerReplicationInfo(Pawn(Other).PlayerReplicationInfo), KFAmmunition(CurInv));
							}
							else
							{
								AmmoPickupAmount = 0.16 * KFAmmunition(CurInv).MaxAmmo;
							}

							KFAmmunition(CurInv).AmmoAmount = Min(KFAmmunition(CurInv).MaxAmmo, KFAmmunition(CurInv).AmmoAmount + AmmoPickupAmount);
							bPickedUp = true;
						}
					}
					else if ( KFAmmunition(CurInv).AmmoAmount < KFAmmunition(CurInv).MaxAmmo && !( Frag1Ammo(CurInv) != none && SRPRI.ClientVeteranSkill == class'SRVetJuggernaut' ) )
					{
						bPickedUp = true;

						if ( FRand() <= (1.0 / Level.Game.GameDifficulty) )
						{
							KFAmmunition(CurInv).AmmoAmount++;
						}
					}
				}
			}

			if ( bPickedUp )
			{
				if ( Role == ROLE_Authority )
				{
					SRPRI.AmmoSupportUsed++;
					if ( Instigator.Controller == Pawn(Other).Controller )
						SRPRI.SelfAmmoSupportUsed++;
				}
				if ( Instigator.Controller == Pawn(Other).Controller )
					PickupMessage = "You've picked up your own ammo box.";
				AnnouncePickup(Pawn(Other));
				GotoState('Sleeping', 'Begin');

				if ( KFGameType(Level.Game) != none )
				{
					KFGameType(Level.Game).AmmoPickedUp(self);
				}
			}
		}
	}
}

defaultproperties
{
     PickupMessage="You've got some ammo support from friendly Juggernaut."
	 DrawScale=0.65
	 RespawnTime=99999999.0
}
